/**
 * 图表交互状态管理
 */
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useChartStore = defineStore('chart', () => {
  // 当前选中的元素
  const selectedCity = ref(null)
  const selectedCategory = ref(null)
  const selectedCompany = ref(null)

  // 设置选中城市
  function setSelectedCity(city) {
    selectedCity.value = city
  }

  // 设置选中类别
  function setSelectedCategory(category) {
    selectedCategory.value = category
  }

  // 设置选中公司
  function setSelectedCompany(company) {
    selectedCompany.value = company
  }

  // 清除所有选中
  function clearSelected() {
    selectedCity.value = null
    selectedCategory.value = null
    selectedCompany.value = null
  }

  return {
    selectedCity,
    selectedCategory,
    selectedCompany,
    setSelectedCity,
    setSelectedCategory,
    setSelectedCompany,
    clearSelected
  }
})

